from visual import *
import ode

class QuadPropeller(object):
    def __init__(self, world, prop_space, prop_pos, prop_size, prop_color):

        self.vis_prop = box(pos = prop_pos, length = prop_size[0], width = prop_size[2], height = prop_size[1])
        self.vis_prop.color = prop_color
        
        self.prop_body = ode.Body(world)
        self.prop_mass = ode.Mass()
        self.prop_mass.setBox(20, prop_size[0], prop_size[1], prop_size[2])
        
        self.prop_body.setPosition(prop_pos)
        
        #prop_geom = ode.GeomBox(lengths = prop_size)
        #prop_geom.setPosition(prop_pos)
        
        #prop_transform = ode.GeomTransform(prop_space)
        #prop_transform.setGeom(prop_geom)
      
        #prop_transform.setBody(self.prop_body)

        self.prop_body.setMass(self.prop_mass)
    
    def update(self):
        self.vis_prop.pos = self.prop_body.getPosition()
        rot = self.prop_body.getRotation()
        self.vis_prop.axis=rot[0], rot[3], rot[6]
        self.vis_prop.up=rot[1], rot[4], rot[7]
        
    def get_body(self):
        return self.prop_body
    
    def get_pos(self):
        return self.vis_prop.pos